package com.zhuxiang.dao.impl;

import com.zhuxiang.dao.ArticleDao;
import com.zhuxiang.domain.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class ArticleDaoImpl implements ArticleDao {
    //注入JdbcTemplate
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public void save(Article article) {
        //编写Sql
        String sql = "insert into t_article values (null,?,?)";

        //调用JdbcTemplate里的update方法
        jdbcTemplate.update(sql,article.getTitle(),article.getContent());
    }
}
